package by.dkusch.aircompany.webapp.page.base;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import by.dkusch.aircompany.webapp.page.base.panels.FooterPanel;
import by.dkusch.aircompany.webapp.page.base.panels.HeaderPanel;
import by.dkusch.aircompany.webapp.page.base.panels.MenuPanel;

public class BaseLayout extends WebPage {
	private static final long serialVersionUID = 1L;

	private Component headerPanel;
	private Component menuPanel;
	private Component footerPanel;
	// private Component languagePanel;

	private int itemsPerPage;
	private Label pageTitle;
	public static final int ITEMS_PER_PAGE_DEFAULT = 10;

	public BaseLayout() {
		this(ITEMS_PER_PAGE_DEFAULT);
	}

	public BaseLayout(int itemsPerPage) {
		super();
		this.itemsPerPage = itemsPerPage;
	}

	@Override
	protected void onInitialize() {
		super.onInitialize();
		add(headerPanel = new HeaderPanel("headerPanel"));
		add(menuPanel = new MenuPanel("menuPanel"));
		add(footerPanel = new FooterPanel("footerPanel"));
		// add(languagePanel = new LanguagePanel("languagePanel"));
		add(pageTitle = new Label("headerTitle", new Model<String>("")));
	}

	@Override
	protected void onConfigure() {
		// TODO Auto-generated method stub
		super.onConfigure();
		pageTitle.setDefaultModel(getPageTitle());
	}

	protected IModel<String> getPageTitle() {
		return new Model<String>(getClass().getSimpleName());
	}

	public Component getHeaderPanel() {
		return headerPanel;
	}

	public void setHeaderPanel(Component headerPanel) {
		this.headerPanel = headerPanel;
	}

	public Component getMenuPanel() {
		return menuPanel;
	}

	public void setMenuPanel(Component menuPanel) {
		this.menuPanel = menuPanel;
	}

	public Component getFooterPanel() {
		return footerPanel;
	}

	public void setFooterPanel(Component footerPanel) {
		this.footerPanel = footerPanel;
	}

	protected int getItemsPerPage() {
		return itemsPerPage;
	}

}
